package cn.ichiva.service;

import org.springframework.data.redis.connection.RedisZSetCommands;
import org.springframework.data.redis.core.ZSetOperations;

import java.util.Collection;
import java.util.List;
import java.util.Set;

public class ZSetService{
    private final ZSetOperations<String,String> zset;

    public ZSetService(ZSetOperations<String, String> zset) {
        this.zset = zset;
    }


    public Boolean add(String key, String value, double score) {
        return zset.add(key, value, score);
    }


    public Long remove(String key, List<String> values) {
        return zset.remove(key, values.toArray(new String[0]));
    }


    public Double incrementScore(String key, String value, double delta) {
        return zset.incrementScore(key, value, delta);
    }


    public Long rank(String key, String o) {
        return zset.rank(key, o);
    }


    public Long reverseRank(String key, String o) {
        return zset.reverseRank(key,o);
    }


    public Set<String> range(String key, long start, long end) {
        return zset.range(key, start, end);
    }


    public Set<String> rangeByScore(String key, double min, double max) {
        return zset.rangeByScore(key, min, max);
    }

    public Set<String> rangeOffsetByScore(String key, double min, double max, long offset, long count) {
        return zset.rangeByScore(key, min, max, offset, count);
    }

    public Set<String> reverseRange(String key, long start, long end) {
        return zset.reverseRange(key,start,end);
    }

    public Set<String> reverseRangeByScore(String key, double min, double max) {
        return zset.reverseRangeByScore(key, min, max);
    }


    public Set<String> reverseRangeOffsetByScore(String key, double min, double max, long offset, long count) {
        return zset.reverseRangeByScore(key, min, max, offset, count);
    }

    public Long count(String key, double min, double max) {
        return zset.count(key, min, max);
    }


    public Long size(String key) {
        return zset.size(key);
    }


    public Long zCard(String key) {
        return zset.zCard(key);
    }


    public Double score(String key, Object o) {
        return zset.score(key, o);
    }


    public Long removeRange(String key, long start, long end) {
        return zset.removeRange(key, start, end);
    }


    public Long removeRangeByScore(String key, double min, double max) {
        return zset.removeRangeByScore(key, min, max);
    }


    public Long unionAndStore(String key, String otherKey, String destKey) {
        return zset.unionAndStore(key, otherKey, destKey);
    }


    public Long unionAndStores(String key, Collection<String> otherKeys, String destKey) {
        return zset.unionAndStore(key, otherKeys, destKey);
    }


    public Long intersectAndStore(String key, String otherKey, String destKey) {
        return zset.intersectAndStore(key, otherKey, destKey);
    }


    public Long intersectAndStores(String key, Collection<String> otherKeys, String destKey) {
        return zset.intersectAndStore(key, otherKeys, destKey);
    }
}
